package com.supervision.manage.mapper.sqlprovider

import com.supervision.domain.bean.po.SmsPO
import org.apache.commons.lang3.StringUtils

class SmsRecordSqlProvider {

    fun getSmsRecordList(param: HashMap<String, Any>): String {
        val po = param["po"] as SmsPO
        val limitSql = param["limitSql"] as String

        val sql = StringBuilder()
        if (limitSql.isEmpty()) {
            sql.append(" select count(*) ")
        } else {
            sql.append(" select sr.*  ")
        }
        sql.append(" from sms_record sr ")
        sql.append(" where sr.weight >= 0 ")
        if (po.caseId > 0) {
            sql.append(" and sr.case_id = #{po.caseId} ")
        }
        sql.append(" order by sr.id desc ")

        return sql.toString() + StringUtils.defaultString(limitSql, StringUtils.EMPTY)
    }
}